﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.IO;
using GameSchoolApplication.Models;
using System.Diagnostics;

namespace GameSchoolApplication.Classes
{
    /// <summary>
    /// The mailer class. This is just a dummy class right now!
    /// TODO: Write this mother
    /// Author:
    /// Date:
    /// </summary>
    public class Mailer
    {
        /// <summary>
        /// Sends a user his lost password via Smtp per request.
        /// TODO: Bæta við filereader sem les email body upp úr template file. Redda öðrum mail account.
        /// Author:Bjarmi
        /// Date: 
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public bool sendLostPasswordMail(UserAccount user)
        {
            string eMailAddress = user.email;
            //string eMailMessage; TODO sækja email upp úr file xml/txt/.config             
            try
            {
                using (MailMessage m = new MailMessage())
                {
                    m.To.Add(eMailAddress);
                    m.Subject = "DoNotReply - Lost password request";
                    m.Body = "hr. " + user.name + "\n\nYour password is: " + user.passW + "\n\nKindly DONT LOSE IT AGAIN!";
                    using (SmtpClient sender = new SmtpClient() )
                    {
                        sender.EnableSsl = true;
                        sender.Send(m);
                    }
                }
            }
            catch (Exception s)
            {
                System.Diagnostics.Debug.WriteLine(s);
                return false;
            }
            return true; 
        }
    }
}